﻿var adminMenuOpen = false;

function toggle(trigger, popupID, e) {
    e = e || window.event;
    trigger.blur();
    iLib.Dom.PreventBubble(e);
    var popup = document.getElementById(popupID);
    var mainBox = document.getElementById("mainBox");
    adminMenuOpen = !adminMenuOpen;
    clearActiveMenuItem();
    if (adminMenuOpen)
        trigger.className = "active";
    cms.Lists.ShowPopup(popup, trigger, "left", -3, iLib.Pos.FindY(mainBox) - 1, true, e);
}

function show(trigger, popupID, e) {
    if (!adminMenuOpen)
        return;
    e = e || window.event;
    iLib.Dom.PreventBubble(e);
    var popup = document.getElementById(popupID);
    var mainBox = document.getElementById("mainBox");
    clearActiveMenuItem();
    trigger.className = "active";
    cms.Lists.ShowPopup(popup, trigger, "left", -3, iLib.Pos.FindY(mainBox) - 1, false, e);
}

function clearActiveMenuItem() {
    var items = document.getElementById("menu").getElementsByTagName("a");
    for (var i = 0; i < items.length; i++) {
        items[i].className = "";
    }
}

